// Copyright 2013 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
es5id: 11.1.1_32
description: >
    Tests that the options minimumSignificantDigits and
    maximumSignificantDigits are read in the right sequence.
author: Norbert Lindenberg
---*/

function Test() {
    var minimumSignificantDigitsRead = false;
    var maximumSignificantDigitsRead = false;

    function readMinimumSignificantDigits() {
        assert.sameValue(minimumSignificantDigitsRead, false,
                         "minimumSignificantDigits getter already called");
        assert.sameValue(maximumSignificantDigitsRead, false,
                         "maximumSignificantDigits getter called before minimumSignificantDigits");
        minimumSignificantDigitsRead = true;
        return 1;
    }

    function readMaximumSignificantDigits() {
        assert.sameValue(maximumSignificantDigitsRead, false,
                         "maximumSignificantDigits getter already called");
        maximumSignificantDigitsRead = true;
        return 1;
    }

    var options = {};
    Object.defineProperty(options, "minimumSignificantDigits",
        { get: readMinimumSignificantDigits });
    Object.defineProperty(options, "maximumSignificantDigits",
        { get: readMaximumSignificantDigits });

    new Intl.NumberFormat("de", options);

    assert(minimumSignificantDigitsRead, "minimumSignificantDigits getter was called once");
    assert(maximumSignificantDigitsRead, "maximumSignificantDigits getter was called once");
}

// preheat
const NUMBER_OF_PREHEAT = 1;
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}

ArkTools.jitCompileAsync(Test);
assert.sameValue(ArkTools.waitJitCompileFinish(Test), true, '[JIT] JIT disabled.');

// test
const NUMBER_OF_TEST = 1; // or 2
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}
